home *** CD-ROM | disk | FTP | other *** search
- VERSION 4.00
- Begin VB.Form Session
- BorderStyle = 3 'Fixed Dialog
- Caption = "FTP Session - (hidden)"
- ClientHeight = 1695
- ClientLeft = 1500
- ClientTop = 2055
- ClientWidth = 4590
- Height = 2100
- Icon = "Session.frx":0000
- Left = 1440
- LinkTopic = "Form1"
- LockControls = -1 'True
- MaxButton = 0 'False
- MinButton = 0 'False
- ScaleHeight = 1695
- ScaleWidth = 4590
- ShowInTaskbar = 0 'False
- Top = 1710
- Width = 4710
- Begin VB.Label lblReadMe
- AutoSize = -1 'True
- Caption = "Host files and directories are returned in the ""Files"" collection and processed in the 'ListFTPItems' proc."
- ForeColor = &H00800000&
- Height = 390
- Index = 2
- Left = 285
- TabIndex = 1
- Top = 900
- Width = 3915
- WordWrap = -1 'True
- End
- Begin CIFTPLib.CIFTP ciSession
- Height = 450
- Left = 300
- Top = 120
- Width = 480
- _Version = 65537
- _ExtentX = 847
- _ExtentY = 794
- _StockProps = 0
- AccessChannelConnectionWAV= ""
- AccessChannelClosedWAV= ""
- DataChannelConnectionWAV= ""
- DataChannelClosedWAV= ""
- FileClosedWAV = ""
- ListBoxesPopulatedWAV= ""
- SocketClosedWAV = ""
- WSAErrorWAV = ""
- HostName = ""
- HostAddress = ""
- RemoteFileName = ""
- LoginName = ""
- Password = ""
- RepresentationType= ""
- WorkingDirectory= "/"
- End
- Begin VB.Label lblReadMe
- Caption = "Crescent FTP Control"
- ForeColor = &H00800000&
- Height = 195
- Index = 0
- Left = 930
- TabIndex = 0
- Top = 285
- Width = 1995
- WordWrap = -1 'True
- End
- Attribute VB_Name = "Session"
- Attribute VB_Creatable = False
- Attribute VB_Exposed = False
- Option Explicit
- '<Public>---------------------------------------------
- Public Connected As Boolean
- Public GotDirectory As Boolean
- Public TimedOut As Boolean
- Public ServerNode As Node
- Public ThisExplorer As Form
- Public ThisCallback As FTPCallback
- Public ThisServer As FTPServer
- Public WorkingDir As String
- '</Public>--------------------------------------------
- '<Private>--------------------------------------------
- Private Alias As String
- Private GetListing As Boolean
- '</Private>-------------------------------------------
- Private Sub ciSession_AccessControlChannelClosed()
- Connected = False
- Call Status.ShowStatus(Alias & ": the access control channel was closed", , , "Status", vbBlue)
- End Sub
- Private Sub ciSession_AccessControlChannelConnection()
- Connected = True
- Call Status.ShowStatus(Alias & ": the access control channel was connected", , , "Status", vbBlue)
- End Sub
- Private Sub ciSession_AccessControlPacketReceived(ByVal Packet As String)
- '---- packet received on the access control channel
- Call Status.ShowStatus(Alias & vbCrLf & Packet, , , "Packet", vbRed)
- End Sub
- Private Sub ciSession_DataControlChannelClosed()
- GotDirectory = True
- Call Status.ShowStatus(Alias & ": the data control channel was closed", , , "Status", vbBlue)
- End Sub
- Private Sub ciSession_DataControlChannelConnection()
- Call Status.ShowStatus(Alias & ": the data control channel was connected", , , "Status", vbBlue)
- End Sub
- Private Sub ciSession_DataControlPacketReceived(ByVal Packet As String, ByVal bytes_in As Integer)
- '---- packet received on the access control channel
- Call Status.ShowStatus(Alias & vbCrLf & Packet, , , "Packet", vbRed)
- End Sub
- Private Sub ciSession_DataPortSet()
- '---- connect to the data channel
- ciSession.ConnectToDataChannel
- End Sub
- Private Sub ciSession_GotDirectory()
- GotDirectory = True
- Call Status.ShowStatus(Alias & ": got directories and files; adding to TreeView", , , "Status", vbBlue)
- If GetListing Then
- '---- turn off redraw on TreeView and ListView
- Call SendMessage(ThisExplorer.Tree.hwnd, WM_SETREDRAW, REDRAWOFF, 0&)
- Call SendMessage(ThisExplorer.List.hwnd, WM_SETREDRAW, REDRAWOFF, 0&)
-
- Call ThisCallback.ListFTPItems(Me, ThisExplorer, ServerNode)
-
- '---- set some properties on the explorer
- ThisExplorer.StatusBar.Panels(1).Text = ThisExplorer.List.ListItems.Count & " object(s)"
- ThisExplorer.Tree.Nodes(ServerNode.Key).Expanded = True
-
- '---- turn redraw back on
- Call SendMessage(ThisExplorer.Tree.hwnd, WM_SETREDRAW, REDRAWON, 0&)
- Call SendMessage(ThisExplorer.List.hwnd, WM_SETREDRAW, REDRAWON, 0&)
- End If
- End Sub
- Private Sub ciSession_GotFile(ByVal lpszRemoteFileName As String, ByVal lpszLocalFileName As String)
- Call Status.ShowStatus(Alias & ": the file was successfully received from the FTP server", , , "Status", vbBlue)
- ThisExplorer.MousePointer = vbDefault
- End Sub
- Private Sub ciSession_InternetError(ByVal error_number As Long, ByVal error_message As String)
- Call Status.ShowStatus(Alias & ": an Internet error occurred - " & error_number, vbRed, True, "Error", vbBlack)
- ThisExplorer.MousePointer = vbDefault
- End Sub
- Private Sub ciSession_PutFile()
- Call Status.ShowStatus(Alias & ": the file was successfully put on the FTP server", , , "Status", vbBlue)
- ThisExplorer.MousePointer = vbDefault
- End Sub
- Private Sub ciSession_WSAError(ByVal error_number As Integer)
- Dim ErrString As String
- Dim ErrConstDescription As String
- Dim ErrDescription As String
- ErrDescription = WSAErrDescription(error_number, ErrConstDescription)
- ErrString = Alias & ": a WSA error occurred - " & Format$(error_number, "") & ", " & ErrConstDescription & ": " & ErrDescription
-
- If (error_number = WSAETIMEDOUT) Then
- TimedOut = True
- End If
- Call Status.ShowStatus(ErrString, vbRed, True, "Error", vbBlack)
- ThisExplorer.MousePointer = vbDefault
- End Sub
- Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
- ciSession.QUIT
- End Sub
- Private Sub Form_Terminate()
- '---- explicitly destroy all objects
- Set ServerNode = Nothing
- Set ThisExplorer = Nothing
- Set ThisCallback = Nothing
- Set ThisServer = Nothing
- End Sub
- '----------------------------------------------------
- '<Purpose> forces this form to transfer data from the
- ' FTPServer class object into the FTP Control
- '----------------------------------------------------
- Public Sub InitSession()
- Dim UsingAddress As Boolean
- Dim UsingName As Boolean
- Alias = ThisServer.Alias
- '---- name and address are mutually exclusive
- UsingName = (ThisServer.HostName <> "")
- If (Not UsingName) Then
- UsingAddress = (ThisServer.HostAddress <> "")
- End If
- '---- improper settings
- If ((Not UsingName) And (Not UsingAddress)) Then Exit Sub
- '---- if the name did not change, outta here
- If (UsingName And (ciSession.HostName = ThisServer.HostName)) Then Exit Sub
- '---- if the address did not change, outta here
- If (UsingAddress And (ciSession.HostAddress = ThisServer.HostAddress)) Then Exit Sub
- '---- since this is a new host, or address, create a session
- With ciSession
- .HostName = ThisServer.HostName
- .HostAddress = ThisServer.HostAddress
- .LoginName = ThisServer.LoginName
- .Password = ThisServer.Password
- .ServerOSType = ThisServer.ServerType
- End With
- End Sub
- '-----------------------------------------------------
- '<Purpose> creates an FTP connection
- '-----------------------------------------------------
- Public Sub Connect()
- Connected = False
- GotDirectory = False
- TimedOut = False
- GetListing = True
- If (WorkingDir = "") Then
- ciSession.WorkingDirectory = "/"
- Else
- ciSession.WorkingDirectory = WorkingDir
- End If
- ciSession.GetDirectory
- Call Status.ShowStatus(Alias & ": connecting for directories and files", , , "Status", vbBlue)
- End Sub
- '------------------------------------------------------
- '<Purpose> transfers a file from the PC to the Host
- '------------------------------------------------------
- Public Sub TransferLocal2Host(LocalFileName As String, FTPDirectory As String, FTPFileName As String)
- Dim TransferFile As String
- '---- allow the user to modify the file name
- TransferFile = InputBox("Host File Name:", "Transfer from My Computer to FTP Server", FTPDirectory & "/" & FTPFileName)
- If (TransferFile = "") Then Exit Sub
- ThisExplorer.MousePointer = vbArrowHourglass
- With ciSession
- .WorkingDirectory = FTPDirectory
- .LocalFileName = LocalFileName
- .RemoteFileName = TransferFile
- .PutFile
- End With
- Call Status.ShowStatus(Alias & ": putting file on server", , , "Status", vbBlue)
- End Sub
- '------------------------------------------------------
- '<Purpose> transfers a file from the Host to the PC
- '------------------------------------------------------
- Public Sub TransferHost2Local(FTPFileName As String, LocalFileName As String)
- Dim TransferFile As String
- '---- allow the user to modify the file name
- TransferFile = InputBox("Local File Name:", "Transfer from FTP Server to My Computer", LocalFileName)
- If (TransferFile = "") Then Exit Sub
- ThisExplorer.MousePointer = vbArrowHourglass
- With ciSession
- .LocalFileName = TransferFile
- .RemoteFileName = FTPFileName
- .GetFile
- End With
- Call Status.ShowStatus(Alias & ": getting file from server", , , "Status", vbBlue)
- End Sub
-